package com.numberone.web.controller.homeliketype;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.numberone.common.annotation.Log;
import com.numberone.common.enums.BusinessType;
import com.numberone.system.domain.HomeLikeType;
import com.numberone.system.service.IHomeLikeTypeService;
import com.numberone.framework.web.base.BaseController;
import com.numberone.common.page.TableDataInfo;
import com.numberone.common.base.AjaxResult;
import com.numberone.common.utils.poi.ExcelUtil;

/**
 * 首页模糊搜素图片 信息操作处理
 * 
 * @author numberone
 * @date 2020-09-28
 */
@Controller
@RequestMapping("/system/homeLikeType")
public class HomeLikeTypeController extends BaseController
{
    private String prefix = "system/homeLikeType";
	
	@Autowired
	private IHomeLikeTypeService homeLikeTypeService;
	
	@RequiresPermissions("system:homeLikeType:view")
	@GetMapping()
	public String homeLikeType()
	{
	    return prefix + "/homeLikeType";
	}
	
	/**
	 * 查询首页模糊搜素图片列表
	 */
	@RequiresPermissions("system:homeLikeType:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(HomeLikeType homeLikeType)
	{
		startPage();
        List<HomeLikeType> list = homeLikeTypeService.selectHomeLikeTypeList(homeLikeType);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出首页模糊搜素图片列表
	 */
	@RequiresPermissions("system:homeLikeType:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(HomeLikeType homeLikeType)
    {
    	List<HomeLikeType> list = homeLikeTypeService.selectHomeLikeTypeList(homeLikeType);
        ExcelUtil<HomeLikeType> util = new ExcelUtil<HomeLikeType>(HomeLikeType.class);
        return util.exportExcel(list, "homeLikeType");
    }
	
	/**
	 * 新增首页模糊搜素图片
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存首页模糊搜素图片
	 */
	@RequiresPermissions("system:homeLikeType:add")
	@Log(title = "首页模糊搜素图片", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(HomeLikeType homeLikeType)
	{		
		return toAjax(homeLikeTypeService.insertHomeLikeType(homeLikeType));
	}

	/**
	 * 修改首页模糊搜素图片
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		HomeLikeType homeLikeType = homeLikeTypeService.selectHomeLikeTypeById(id);
		mmap.put("homeLikeType", homeLikeType);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存首页模糊搜素图片
	 */
	@RequiresPermissions("system:homeLikeType:edit")
	@Log(title = "首页模糊搜素图片", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(HomeLikeType homeLikeType)
	{		
		return toAjax(homeLikeTypeService.updateHomeLikeType(homeLikeType));
	}
	
	/**
	 * 删除首页模糊搜素图片
	 */
	@RequiresPermissions("system:homeLikeType:remove")
	@Log(title = "首页模糊搜素图片", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(homeLikeTypeService.deleteHomeLikeTypeByIds(ids));
	}
	
}
